/***********************************************************************************
** @file	WMIConnectionMngTest.h
** @author	Carlos Armando Orellana Pacolla
** @author  Nestor Felipe
** @date	Jul 28, 2010
**
** @desc	This class test the WMIConnectionMng methods
************************************************************************************/

#include "../Unit--/unit--.h"
#include <cstdio>
#include "../../WConstants.h"
#include "../../WMIConnectionMng.h"

using namespace unit_minus;

testSuite(POCSuite);

/**
* Test the createConnection method for local connection
*/
testCase(createConnectionTest_local, POCSuite)
{
    cout << "------- Start WMIConnectionMng::createConnectionTest_local Test -------" << endl;
	WMIConnectionMng* wmiMng = new WMIConnectionMng();
	wmiMng->initCOMSecurityConfiguration();
	WMIConnection wmiConnection;

	WHResult *expected = new WHResult(L"", W_OK, 0);
	WHResult *result = wmiMng->createConnection(PC_USER, PC_PASSWORD, PC_NAMESPACE, wmiConnection);

	assertTrue(equalValueInfo(expected->getHRESULT(), result->getHRESULT()));

	result = wmiMng->createConnection(PC_USER, PC_PASSWORD, PC_LOCAL_PASSWORD, wmiConnection);

	assertTrue(result->getHRESULT() != 0);

	wmiConnection.close();

	delete wmiMng;
    delete result;
    delete expected;
    cout << "------- End WMIConnectionMng::createConnectionTest_local Test -------" << endl;
    cout << endl;
    system("PAUSE");
}

/**
* Test the createConnection method for local connection
*/
testCase(createConnectionTest_remote, POCSuite)
{
    cout << "-------- Start WMIConnectionMng::createConnectionTest_remote --------" << endl;
	WMIConnectionMng* wmiMng = new WMIConnectionMng();
	wmiMng->initCOMSecurityConfiguration();
	WMIConnection wmiConnection;

	WHResult *expected = new WHResult(L"", W_OK, 0);
	WHResult *result = wmiMng->createConnection(PC_USER, PC_PASSWORD, PC_IP_REMOTE_HOST, PC_NAMESPACE, wmiConnection);

	assertTrue(equalValueInfo(expected->getHRESULT(), result->getHRESULT()));
	
	wmiConnection.close();
	delete wmiMng;
    delete result;
    delete expected;
    cout << "-------- End WMIConnectionMng::createConnectionTest_remote Test --------" << endl;
    cout << endl;
    system("PAUSE");
}